import Request from '@/libs/request'
import {selectDictItemByCode} from './dict'

// interface AddPmGroupDept extends Omit<Evaluation.PmGroupDimension, 'pmGroupId' | 'pmGroupDimensionId' | 'pmGroupDimensionTargetList'> {
//   pmGroupDimensionTargetList: Omit<Evaluation.PmGroupDimensionTarget, 'pmGroupDimensionTargetId' | 'pmGroupDimensionId'>[]
// }

// interface AddPmProgressSet extends Omit<Evaluation.PmProgressSet, 'pmGroupProgressId' | 'pmGroupProgressSetList'> {
//   pmGroupProgressSetList: AddPmProgressSet[] | null
// }

// interface AddPmGroupProgress extends Omit<Evaluation.PmGroupProgress, 'pmGroupId' | 'pmProgressSetList'> {
//   pmProgressSetList: AddPmProgressSet
// }

// 查询模板流程 ，包括流程设置
export const selectAllProgressTem = () =>
  Request.get<Evaluation.Progress[]>('/pmGroupProgressTem/selectAllProgressTem')

/** 添加考评组*/
export const addPmGroup = (data: Evaluation.AddEvalutaionData) =>
  Request.post<null>('/pmGroup/addPmGroup', data)

/** 查询考评组*/
export const selectPmGroupByPage = (data: {pmGroupName?: string} & Paging) =>
  Request.get<PagingResponse<Evaluation.TableData>>('/pmGroup/selectPmGroupByPage', data)

/** 查询单个考评组详细数据*/
export const selectPmGroupById = (data: {pmGroupId: string | number}) =>
  Request.get<Evaluation.EvalutaionData>('/pmGroup/selectPmGroupById', data)

/** 修改单个考评组详细数据*/
export const editPmGroup = (data: Evaluation.EvalutaionData) =>
  Request.post<null>('/pmGroup/editPmGroup', data, {successMessage: false})

/** 删除考勤组*/
export const deletePmGroup = (data: {pmGroupId: number}) =>
  Request.get<null>('/pmGroup/deletePmGroup', data)

/**周期类型类型--查询 */
export const selectPeriodTypeByTypeCode = () =>
  selectDictItemByCode<'008', string>({typeCode: '008'})

/** 通过周期类型查询考核组*/
export const selectPmGroupByPmPeriodCode = (data: {pmPeriodCode: string}) =>
  Request.get<
    {
      pmGroupId: number
      pmGroupName: string
      userCount: number
      deptCount: number
    }[]
  >('/pmGroup/selectPmGroupByPmPeriodCode', data)

/** 通过周期类型查询考核组*/
export const startPmForm = (data: {
  pmGroupIds: number[]
  datePeriodTypeCode: string
  pmFormName: string
  startUserDDId: string
  dateCount?: string
  dateYear?: string
}) => Request.post<null>('/pmForm/startPmForm', data)
